@extends('layouts.app')

@section('title')
    后台-库存管理-规整盒子
@stop

@section('extcss')
    <!--ext css-->
    <style>
        .btn-color {
            color: #93A2B2;
            border: 1px solid rgba(221, 226, 232, 0.49);
        }

        .table > tbody > tr > td, .table > tbody > tr > th, .table > tfoot > tr > td, .table > tfoot > tr > th, .table > thead > tr > td, .table > thead > tr > th {
            vertical-align: middle;
        }
    </style>
    <!-- /ext css-->
@stop

@section('content')
    <!-- page content -->
    <div class="right_col" role="main">
        <div class="">
            <div class="page-title">
                <div class="title_left">
                    <h3>规整盒子</h3>
                </div>

                <div class="title_right">
                    <div class="col-md-5 col-sm-12 form-group pull-right top_search">
                        <div class="input-group">
                            <input id="txtKeyWorld" type="text" class="form-control" placeholder="查找手机号码、物流单号">
                                <span class="input-group-btn">
                                  <button id="btnSearch" class="btn btn-default" type="button"><i class="fa fa-search" title="查找手机号码、物流单号"></i></button>
                                </span>
                        </div>
                    </div>
                    <div class="col-md-7 col-sm-12 form-group pull-right top_search text-right">
                        <a href="{{url('system/assort/index')}}" class="btn btn-round btn-default btn-color"
                           type="button" title="新增" style="display:none;"><i class="fa fa-plus"></i></a>
                        <button id="btnSelectAll" class="btn btn-round btn-default btn-color" type="button" title="删除" style="display: none;">
                            <i class="fa fa-trash"></i></button>
                        <a href="javascript:window.location.reload();" class="btn btn-round btn-default btn-color"
                           type="button" title="刷新"><i class="fa fa-refresh"></i></a>
                        <button class="btn btn-round btn-default btn-color" type="button" title="下载" style="display: none;"><i
                                    class="fa fa-download"></i></button>
                        <button class="btn btn-round btn-default btn-color" type="button" title="打印" style="display: none;"><i
                                    class="fa fa-print"></i></button>
                    </div>
                </div>
            </div>

            <div class="clearfix"></div>
            <!--正常查询数据-->
            <div class="row">
                <div class="col-md-12 col-sm-12 col-xs-12">
                    <div class="x_panel">
                        <div class="x_title">
                            <h2>盒子入库</h2>
                            <ul class="nav navbar-right panel_toolbox">
                                <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                </li>
                            </ul>
                            <div class="clearfix"></div>
                        </div>

                        <div class="x_content">
                            <div class="table-responsive">
                                <table class="table table-striped jambo_table bulk_action">
                                    <thead>
                                    <tr class="headings">
                                        <th class="column-title">订单号</th>
                                        <th class="column-title">姓名</th>
                                        <th class="column-title">地址</th>
                                        <th class="column-title">电话</th>
                                        <th class="column-title">状态</th>
                                        <th class="column-title">出库物流</th>
                                        <th class="column-title">物流单号</th>
                                        <th class="column-title">回库物流</th>
                                        <th class="column-title">物流单号</th>
                                        <th class="column-title">详情</th>
                                        <th class="column-title">操作</th>
                                    </tr>
                                    </thead>

                                    <tbody id="storeRow">
                                    @forelse($boxs as $box)
                                        <tr class="even pointer">
                                            <td class=" ">{{\Carbon\Carbon::parse($box->created_at)->format('YmdHis')}}</td>
                                            <td class=" ">{{$box->name}}</td>
                                            <td class=" ">{{$box->address}}</td>
                                            <td class=" ">{{$box->mobile}}</td>
                                            <td class=" "><button name="btnState" type="button" class="btn btn-success btn-xs" data-orderno="{{$box->orderno}}" disabled>{{$box->state->key}}</button></td>
                                            <td class=" ">{{$box->express_out_company}}</td>
                                            <td class=" ">{{$box->express_out_no}}</td>
                                            <td class=" ">{{$box->express_in_company}}</td>
                                            <td class=" ">{{$box->express_in_no}}</td>
                                            <td class=" "><a href="#box_{{$box->id}}" data-toggle="collapse"
                                                             aria-expanded="false" aria-controls="box_{{$box->id}}"
                                                             title="展开详细信息"><i class="fa fa-ellipsis-h"></i></a></td>
                                            <td class=" ">
                                                @if($box->state->val>=6)
                                                    <button class="btn btn-success btn-xs btn_allstore" data-boxorderno="{{$box->orderno}}" data-state="6" title="全部入库" disabled><i class="fa fa-cubes fa-1x"></i></button>
                                                @else
                                                    <button class="btn btn-success btn-xs btn_allstore" data-boxorderno="{{$box->orderno}}" data-state="6" title="全部入库"><i class="fa fa-cubes fa-1x"></i></button>
                                                @endif
                                            </td>
                                        </tr>
                                        <tr class="collapse in" id="box_{{$box->id}}">
                                            <td colspan="12">
                                            @foreach($box->Assorts as $assort)
                                                <!--item-->
                                                    <div class="col-md-3 col-xs-12 widget widget_tally_box">
                                                        <div class="x_panel ui-ribbon-container">

                                                            <div class="x_content">
                                                                <div style="text-align: center; margin-bottom: 17px">
                                                                    <img class="img-thumbnail"
                                                                         src="{{asset("upload/images/".($assort->img ==null ? "default.png":pathinfo($assort->img)["basename"]))}}">
                                                                </div>
                                                                <div>
                                                                    <ul class="list-inline widget_tally">
                                                                        <li>
                                                                            <div class="form-group">
                                                                                <label class="cartlabel control-label col-md-4 col-sm-3 col-xs-3">款号</label>
                                                                                <div class="col-md-8 col-sm-9 col-xs-9">
                                                                                    <span class="" style="font-size: 20px"><mark>{{$assort->serial}}</mark></span>
                                                                                </div>
                                                                            </div>
                                                                        </li>
                                                                        <li>
                                                                            <div class="form-group">
                                                                                <label class="cartlabel control-label col-md-4 col-sm-3 col-xs-3">尺码</label>
                                                                                <div class="col-md-8 col-sm-9 col-xs-9">
                                                                                    <span class="lead"><mark>{{$assort->size}}</mark></span>
                                                                                </div>
                                                                            </div>
                                                                        </li>
                                                                        <li>
                                                                            <div class="form-group">
                                                                                <label class="cartlabel control-label col-md-4 col-sm-3 col-xs-3">颜色</label>
                                                                                <div class="col-md-8 col-sm-9 col-xs-9">
                                                                                    <span class="lead"><mark>{{$assort->color}}</mark></span>
                                                                                </div>
                                                                            </div>
                                                                        </li>
                                                                        <li>
                                                                            <div class="form-group">
                                                                                <label class="cartlabel control-label col-md-4 col-sm-3 col-xs-3">分类</label>
                                                                                <div class="col-md-8 col-sm-9 col-xs-9">
                                                                                    <span class="lead"><mark>{{$assort->category}}</mark></span>
                                                                                </div>
                                                                            </div>
                                                                        </li>
                                                                        <li>
                                                                            <div class="form-group">
                                                                                <label class="cartlabel control-label col-md-4 col-sm-3 col-xs-3">数量</label>
                                                                                <div class="col-md-8 col-sm-9 col-xs-9">
                                                                                    <span class="lead"><mark>{{$assort->number}}</mark></span>
                                                                                </div>
                                                                            </div>
                                                                        </li>
                                                                        <li>
                                                                                @if($assort->state->val>5)
                                                                                <div class="form-group">
                                                                                    <label class="cartlabel control-label col-md-4 col-sm-3 col-xs-3">状态</label>
                                                                                    <div class="col-md-8 col-sm-9 col-xs-9">
                                                                                        <span class="lead"><mark>{{$assort->state->key}}</mark></span>
                                                                                    </div>
                                                                                </div>
                                                                                @else
                                                                                <div class="row">
                                                                                    <div class="col-md-4 col-sm-9 col-xs-9"><button class="btn btn-default btn-block btn_store" data-id="{{$assort->id}}" data-boxorderno="{{$assort->orderno}}" data-state="8" title="污损"><i class="fa fa-ban"></i></button></div>
                                                                                    <div class="col-md-4 col-sm-9 col-xs-9"><button class="btn btn-default btn-block btn_store" data-id="{{$assort->id}}" data-boxorderno="{{$assort->orderno}}" data-state="7" title="已经售出"><i class="fa fa-jpy"></i></button></div>
                                                                                    <div class="col-md-4 col-sm-9 col-xs-9"><button class="btn btn-default btn-block btn_store" data-id="{{$assort->id}}" data-boxorderno="{{$assort->orderno}}" data-state="6" title="整理入库"><i class="fa fa-cubes"></i></button></div>
                                                                                </div>
                                                                                @endif
                                                                        </li>
                                                                    </ul>
                                                                    <div class="clearfix"></div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <!-- /item-->
                                                @endforeach
                                            </td>
                                        </tr>
                                    @empty
                                        <tr class="even pointer">
                                            <td class="a-center text-center" colspan="13">
                                                没有查到记录
                                            </td>
                                        </tr>
                                    @endforelse
                                    </tbody>
                                    <tfoot>
                                    　　
                                    <tr>
                                        　　
                                        <td colspan="12">
                                            　　　@if($errors->any())
                                                <ul class="list-group">
                                                    @foreach($errors->all() as $error)
                                                        <li class="list-group-item list-group-item-danger">{{$error}}</li>
                                                    @endforeach
                                                </ul>
                                            @endif
                                        </td>
                                        　　
                                    </tr>
                                    　
                                    </tfoot>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--/正常查询数据-->
            <!--历史查询数据-->
            <div class="row">
                <div class="col-md-12 col-sm-12 col-xs-12">
                    <div class="x_panel">
                        <div class="x_title">
                            <h2>操作历史查询</h2>
                            <ul class="nav navbar-right panel_toolbox">
                                <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                </li>
                            </ul>
                            <div class="clearfix"></div>
                        </div>

                        <div class="x_content">
                            <div class="table-responsive">
                                <table class="table table-striped jambo_table bulk_action">
                                    <thead>
                                    <tr class="headings">
                                        <th class="column-title">订单号</th>
                                        <th class="column-title">姓名</th>
                                        <th class="column-title">地址</th>
                                        <th class="column-title">电话</th>
                                        <th class="column-title">状态</th>
                                        <th class="column-title">出库物流</th>
                                        <th class="column-title">物流单号</th>
                                        <th class="column-title">回库物流</th>
                                        <th class="column-title">物流单号</th>
                                        <th class="column-title">详情</th>
                                        <th class="column-title">操作</th>
                                    </tr>
                                    </thead>

                                    <tbody>
                                    @forelse($historyboxs as $box)
                                        <tr class="even pointer">
                                            <td class=" ">{{\Carbon\Carbon::parse($box->created_at)->format('YmdHis')}}</td>
                                            <td class=" ">{{$box->name}}</td>
                                            <td class=" ">{{$box->address}}</td>
                                            <td class=" ">{{$box->mobile}}</td>
                                            <td class=" "><button name="btnState" type="button" class="btn btn-success btn-xs" data-orderno="{{$box->orderno}}" disabled>{{$box->state->key}}</button></td>
                                            <td class=" ">{{$box->express_out_company}}</td>
                                            <td class=" ">{{$box->express_out_no}}</td>
                                            <td class=" ">{{$box->express_in_company}}</td>
                                            <td class=" ">{{$box->express_in_no}}</td>
                                            <td class=" "><a href="#box_{{$box->id}}" data-toggle="collapse"
                                                             aria-expanded="false" aria-controls="box_{{$box->id}}"
                                                             title="展开详细信息"><i class="fa fa-ellipsis-h"></i></a></td>
                                            <td class=" "><button class="btn btn-success btn-xs btn_allstore" data-boxorderno="{{$box->orderno}}" data-state="6" title="全部入库" disabled><i class="fa fa-cubes fa-1x"></i></button></td>
                                        </tr>
                                        <tr class="collapse" id="box_{{$box->id}}">
                                            <td colspan="12">
                                            @foreach($box->Assorts as $assort)
                                                <!--item-->
                                                    <div class="col-md-3 col-xs-12 widget widget_tally_box">
                                                        <div class="x_panel ui-ribbon-container">

                                                            <div class="x_content">
                                                                <div style="text-align: center; margin-bottom: 17px">
                                                                    <img class="img-thumbnail"
                                                                         src="{{asset("upload/images/".($assort->img ==null ? "default.png":pathinfo($assort->img)["basename"]))}}">
                                                                </div>
                                                                <div>
                                                                    <ul class="list-inline widget_tally">
                                                                        <li>
                                                                            <div class="form-group">
                                                                                <label class="cartlabel control-label col-md-4 col-sm-3 col-xs-3">款号</label>
                                                                                <div class="col-md-8 col-sm-9 col-xs-9">
                                                                                    <span class="" style="font-size: 20px"><mark>{{$assort->serial}}</mark></span>
                                                                                </div>
                                                                            </div>
                                                                        </li>
                                                                        <li>
                                                                            <div class="form-group">
                                                                                <label class="cartlabel control-label col-md-4 col-sm-3 col-xs-3">尺码</label>
                                                                                <div class="col-md-8 col-sm-9 col-xs-9">
                                                                                    <span class="lead"><mark>{{$assort->size}}</mark></span>
                                                                                </div>
                                                                            </div>
                                                                        </li>
                                                                        <li>
                                                                            <div class="form-group">
                                                                                <label class="cartlabel control-label col-md-4 col-sm-3 col-xs-3">颜色</label>
                                                                                <div class="col-md-8 col-sm-9 col-xs-9">
                                                                                    <span class="lead"><mark>{{$assort->color}}</mark></span>
                                                                                </div>
                                                                            </div>
                                                                        </li>
                                                                        <li>
                                                                            <div class="form-group">
                                                                                <label class="cartlabel control-label col-md-4 col-sm-3 col-xs-3">分类</label>
                                                                                <div class="col-md-8 col-sm-9 col-xs-9">
                                                                                    <span class="lead"><mark>{{$assort->category}}</mark></span>
                                                                                </div>
                                                                            </div>
                                                                        </li>
                                                                        <li>
                                                                            <div class="form-group">
                                                                                <label class="cartlabel control-label col-md-4 col-sm-3 col-xs-3">数量</label>
                                                                                <div class="col-md-8 col-sm-9 col-xs-9">
                                                                                    <span class="lead"><mark>{{$assort->number}}</mark></span>
                                                                                </div>
                                                                            </div>
                                                                        </li>
                                                                        <li>
                                                                            <div class="form-group">
                                                                                <label class="cartlabel control-label col-md-4 col-sm-3 col-xs-3">状态</label>
                                                                                <div class="col-md-8 col-sm-9 col-xs-9">
                                                                                    <span class="lead"><mark>{{$assort->state->key}}</mark></span>
                                                                                </div>
                                                                            </div>
                                                                        </li>
                                                                    </ul>
                                                                    <div class="clearfix"></div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <!-- /item-->
                                                @endforeach
                                            </td>
                                        </tr>
                                    @empty
                                        <tr class="even pointer">
                                            <td class="a-center text-center" colspan="13">
                                                没有查到记录
                                            </td>
                                        </tr>
                                    @endforelse
                                    </tbody>
                                    <tfoot>
                                    　　
                                    <tr>
                                        　　
                                        <td colspan="12">
                                            　　　@if($errors->any())
                                                <ul class="list-group">
                                                    @foreach($errors->all() as $error)
                                                        <li class="list-group-item list-group-item-danger">{{$error}}</li>
                                                    @endforeach
                                                </ul>
                                            @endif
                                        </td>
                                        　　
                                    </tr>
                                    　
                                    </tfoot>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--/历史查询数据-->
        </div>
    </div>
    <!-- /page content -->
@stop

@section('extjs')


    <!--ext js-->
    <!--search key world-->
    <script>
        $("#btnSearch").click(function () {
            var keyworld = $("#txtKeyWorld").val();

            window.location.href='/system/store/'+keyworld;
        });
    </script>
    <!--search key world-->

    <!--all store-->
    <script>
        $(document).ready(function () {

            $('.btn_allstore').click(function () {

                var orderno = $(this).attr('data-boxorderno');
                var state = $(this).attr('data-state');

                $.ajax({
                    url: "{{url('system/store/')}}" + "/" + orderno+"/"+state+"/allstore"
                    , async: true
                    , type: "GET"
                    , headers: {'X-CSRF-TOKEN': '{{ csrf_token() }}'}
                    , success: function (result) {
                        if(result.state){
                            $('#storeRow').html('');
                            window.location.href="{{url('system/store/')}}";
                        }
                    }
                });

            });
        });
    </script>
    <!-- /all store-->

    <!--all store-->
    <script>
        $(document).ready(function () {

            $('.btn_store').click(function () {

                var orderno = $(this).attr('data-boxorderno');
                var state = $(this).attr('data-state');
                var assortid = $(this).attr('data-id');
                $.ajax({
                    url: "{{url('system/store/')}}" + "/" + orderno+"/"+assortid+"/"+state+"/store"
                    , async: true
                    , type: "GET"
                    , headers: {'X-CSRF-TOKEN': '{{ csrf_token() }}'}
                    , success: function (result) {
                        if(result.state){
                            if(result.count<1) {
                                $('#storeRow').html('');
                                window.location.href="{{url('system/store/')}}";
                            }else {
                                window.location.reload();
                            }
                        }
                    }
                });
            });
        });
    </script>
    <!-- /all store-->
    <!-- /ext js-->
@stop